package com.iqiyi.pps.epg.core.model.sginal;

import com.iqiyi.pps.epg.api.model.web.sginal.TServer;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Created by zhang on 2017/4/26.
 */
@Entity
@Table(name = "server_ip")
@Cache(usage = CacheConcurrencyStrategy.NONE)
public class Server {

    public static final int STATUS_IS_DELETE = -1;
    public static final int STATUS_ZZD = 9;
    public static final int STATUS_INCLUDE = 12;
    public static final int NOT_ASSIGNED_CLUSTER = -1;
    public static final String ERROR_Threshold="020";

    private int id;
    private String sn;
    private String insideServerIp;
    private String outsideServerIp;
    private String port;
    private String province;
    private String city;
    private int status;
    private int serverType;
    private String idc;
    private String system;
    private String version;
    private String hardware;
    private Double load;
    private String remark;
    private Timestamp addTime;
    private Timestamp updateTime;

    private String freeSwapPer;
    private String dataFreePer;
    private String allFreePer;
    private String availableMemPer;
    private String inIcmploss;
    private String outIcmploss;

    private int including;
    private int cluster=NOT_ASSIGNED_CLUSTER;
    private int monitor=-2;//-2: no data, -1:多种异常, 0:ok, 1: /data, 2: /, 3: mem, 4: swap,
    private String cluster_name;
    private int now_including=0;




    public TServer convertThriftModel() {
        TServer tServer = new TServer();
        tServer.setId(this.id);
        tServer.setSn(this.sn);
        tServer.setInsideServerIp(this.insideServerIp);
        tServer.setOutsideServerIp(this.outsideServerIp);
        tServer.setPort(this.port);
        tServer.setProvince(this.province);
        tServer.setCity(this.city);
        tServer.setStatus(this.status);
        tServer.setServerType(this.serverType);
        tServer.setIdc(this.idc);
        tServer.setSystem(this.system);
        tServer.setVersion(this.version);
        tServer.setHardware(this.hardware);
        tServer.setRemark(this.remark);
        tServer.setUpdateTime(this.updateTime.toString());
        tServer.setAddTime(this.addTime.toString());
        tServer.setLoad(this.load != null ? this.load.toString() : "0");

        tServer.setDataFreePer(this.dataFreePer+"");
        tServer.setAllFreePer(this.allFreePer+"");
        tServer.setAvailableMemPer(this.availableMemPer+"");
        tServer.setFreeSwapPer(this.freeSwapPer+"");
        tServer.setInIcmploss(this.inIcmploss+"");
        tServer.setOutIcmploss(this.outIcmploss+"");
        tServer.setMonitor(this.monitor);

        tServer.setIncluding(this.including);
        tServer.setCluster(this.cluster);
        tServer.setCluster_name(this.cluster_name+"");
        tServer.setNow_including(this.now_including);
        return tServer;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name="province")
    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    @Column(name="city")
    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @Column(name="status")
    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    @Column(name="server_type")
    public int getServerType() {
        return serverType;
    }

    public void setServerType(int serverType) {
        this.serverType = serverType;
    }

    @Column(name="remark")
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Column(name="add_time")
    public Timestamp getAddTime() {
        return addTime;
    }

    public void setAddTime(Timestamp addTime) {
        this.addTime = addTime;
    }

    @Column(name="update_time", insertable = false, updatable = false)
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    @Column(name="sn")
    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    @Column(name="inside_server_ip")
    public String getInsideServerIp() {
        return insideServerIp;
    }

    public void setInsideServerIp(String insideServerIp) {
        this.insideServerIp = insideServerIp;
    }

    @Column(name="outside_server_ip")
    public String getOutsideServerIp() {
        return outsideServerIp;
    }

    public void setOutsideServerIp(String outsideServerIp) {
        this.outsideServerIp = outsideServerIp;
    }

    @Column(name="port")
    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    @Column(name="idc")
    public String getIdc() {
        return idc;
    }

    public void setIdc(String idc) {
        this.idc = idc;
    }

    @Column(name="system")
    public String getSystem() {
        return system;
    }

    public void setSystem(String system) {
        this.system = system;
    }

    @Column(name="version")
    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    @Column(name="hardware")
    public String getHardware() {
        return hardware;
    }

    public void setHardware(String hardware) {
        this.hardware = hardware;
    }

    @Column(name="load_value")
    public Double getLoad() {
        return load;
    }

    public void setLoad(Double load) {
        this.load = load;
    }

    @Column(name="free_swap_per")
    public String getFreeSwapPer() {
        return freeSwapPer;
    }

    public void setFreeSwapPer(String freeSwapPer) {
        this.freeSwapPer = freeSwapPer;
    }

    @Column(name="data_free_per")
    public String getDataFreePer() {
        return dataFreePer;
    }

    public void setDataFreePer(String dataFreePer) {
        this.dataFreePer = dataFreePer;
    }

    @Column(name="all_free_per")
    public String getAllFreePer() {
        return allFreePer;
    }

    public void setAllFreePer(String allFreePer) {
        this.allFreePer = allFreePer;
    }

    @Column(name="available_mem_per")
    public String getAvailableMemPer() {
        return availableMemPer;
    }

    public void setAvailableMemPer(String availableMemPer) {
        this.availableMemPer = availableMemPer;
    }

    @Column(name="inIcmploss")
    public String getInIcmploss() {
        return inIcmploss;
    }

    public void setInIcmploss(String inIcmploss) {
        this.inIcmploss = inIcmploss;
    }

    @Column(name="outIcmploss")
    public String getOutIcmploss() {
        return outIcmploss;
    }

    public void setOutIcmploss(String outIcmploss) {
        this.outIcmploss = outIcmploss;
    }

    @Column(name="monitor")
    public int getMonitor() {
        return monitor;
    }

    public void setMonitor(int monitor) {
        this.monitor = monitor;
    }

    @Column(name="max_including")
    public int getIncluding() {
        return including;
    }

    public void setIncluding(int including) {
        this.including = including;
    }

    @Column(name="cluster_id")
    public int getCluster() {
        return cluster;
    }

    public void setCluster(int cluster) {
        this.cluster = cluster;
    }

    @Transient
    public String getClusterName() {
        return cluster_name;
    }

    public void setClusterName(String cluster_name) {
        this.cluster_name = cluster_name;
    }

    @Transient
    public int getNow_including() {
        return now_including;
    }

    public void setNow_including(int now_including) {
        this.now_including = now_including;
    }
}
